<?php
class DeathOutsideInfo extends ORDataObject{
	var $death_outside_info_id		= '';
	var $patient_id					= '';
	var $doctor_id 					= '';
	var $check_in_time 				= '';
	var $aid_giver_name 			= '';
	var $aid_giver_address 			= '';
	var $aid_giver_phone 			= '';
	var $relative_contacts 			= '';
	var $patient_possesion 			= '';
	var $description_pulse 			= '';
	var $description_respiratory 	= '';
	var $description_pupillary_distance	= '';
	var $description_light_reflex	= '';
	var $description_other 			= '';
	var $medication_process 		= '';
	var $death_caution 				= '';
	var $conclusion 				= '';
	var $participant_nurse 			= '';
	var $participant_others 		= '';
	
	/**
	 * DB Table
	 */
	var $_table = 'death_outside_info';

	/**
	 * Primary Key
	 */
	var $_key = 'death_outside_info_id';

	/**
	 * Internal Name
	 */
	var $_internalName = 'DeathOutsideInfo';
	
	/**
	 * Handle instantiation
	 */
	public function DeathOutsideInfo() {
		parent::ORDataObject();
	}
	
	public function getLatestObjectByPatientId($patientId){
		$sql  =   "SELECT MAX($this->_key) id FROM $this->_table WHERE patient_id=$patientId";
		$res  =   $this->_execute($sql);
		$obj  =   Celini::newORDO('DeathOutsideInfo', $res->fields['id']);
		return $obj;
	}
	
	public function getPatientId(){
		return $this->patient_id;
	}

	public function getDoctorId(){
		return $this->doctor_id;
	}

	public function getDeathCaution(){
		return $this->death_caution;
	}

	public function getConclusion(){
		return $this->conclusion;
	}

	public function getCheckInDate(){
        return $this->getLocalizedDate('check_in_time');
    }

    public function getPulse(){
    	return $this->description_pulse;
    }

    public function getRespiratory(){
        return $this->description_respiratory;
    }

    public function getPupillaryDimension(){
        return $this->description_pupillary_distance;
    }

    public function getLightReflection(){
        return $this->description_light_reflex;
    }

    public function getOtherDescription(){
        return $this->description_other;
    }

    public function getCheckInTime($type='hh:mm'){
        $time  =   $this->getLocalizedDate('check_in_time', 'short', 'time');
        $parts =   explode(':', $time);
        switch (strtolower($type)){
        	case 'hh':
        	   return $parts[0];
        	   break;
        	case 'mm':
        	   return $parts[1];
               break;
            case 'hh:mm':
               return $parts[0] . ":" . $parts[1];
               break;
            default:
               return $time;
               break;
        }
    }
    
    public function getPatientPossesion(){
    	return $this->patient_possesion;
    }
	
}
?>